"use strict";

$(".pay-type").click(function () {
  $(".pay-type").removeClass("payment-tab-0"), $(".pay-type").addClass("payment-tab-1"), $(this).addClass("payment-tab-0");var t = $(this).index();$(".pay-type-content").css("display", "none"), $(".pay-type-content").eq(t).css("display", "block");
});var sn = getQueryVariable("sn"),
    price = getQueryVariable("price");sn && price || (location.href = "./404.html"), "QF" != sn.substr(0, 2) && (location.href = "./404.html"), $(".amount-price").html(price), $.get("/api/user/info.jsp", { token: token }, function (t) {
  $(".fmb").text("\uFF08\u4F59\u989D\uFF1A" + t.data.money + "\uFF09");
}, "json"), $(".payment-submit").click(function () {
  var e = $("#thirdpart_pay_wxqrpay").prop("checked"),
      a = $("#thirdpart_pay_alipay").prop("checked"),
      n = $("#thirdpart_pay_fmb").prop("checked");e || a || n ? n ? $.post("/api/fmb/pay.jsp", { sn: sn, token: token }, function (t) {
    200 == t.meta.state ? (swal({ title: "支付成功，跳转中...", text: "神龙教商城提示!", icon: "success", button: "确定!" }), setTimeout(function () {
      location.href = "./order.html";
    }, 1500)) : swal({ title: t.meta.msg, text: "神龙教商城提示!", icon: "error", button: "确定!" });
  }, "json") : a ? location.href = "http://kg.zhaodashen.cn/mt/web/alipay/pagepay/pagepay.jsp?trade_no=" + sn + "&amount=" + price : e && ($.get("/api/wxpay/native.jsp?out_trade_no=" + sn, {}, function (t) {
    $(".modal-qr .box").attr("src", ""), jQuery(".modal-qr .box").qrcode({ width: 200, height: 200, render: "canvas", foreground: "#000", background: "#FFF", text: t });
  }, "text"), t = setInterval(function () {
    $.post("/api/wxpay/ispay.jsp?out_trade_no=" + sn, {}, function (e) {
      201 == e.meta.state && (clearInterval(t), swal({ title: "支付成功，跳转中...", text: "神龙教商城提示!", icon: "success", button: "确定!" }), setTimeout(function () {
        location.href = "./order.html";
      }, 1500));
    }, "json");
  }, 1e3), $(".weixinqr-modal").css("display", "block"), $(".modal-mask").click(function () {
    $(".weixinqr-modal").css("display", "none"), clearInterval(t);
  })) : swal({ title: "请选择支付方式", text: "神龙教商城提示!", icon: "success", button: "确定!" });
});